const app = getApp();
const db = wx.cloud.database()
Page({
    data: {
        bannerList: [],
        bannerIndex: 0,
        videoList:[],
        cardList: [
        //     {
        //     img: '/images/cardNav/1.jpg',
        //     text: '品牌实力',
        //     en: 'Brand Strength',
        //     url: '/pages/product/index/index'
        // }, 
        {
            img: '/images/cardNav/2.jpg',
            text: '产品中心',
            en: 'Product Center',
            url: '/pages/product/index/index'
        }, 
        // {
        //     img: '/images/cardNav/5.jpg',
        //     text: '客户案例',
        //     en: 'Client Case',
        //     url: '/pages/case/index/index'
        // }, 
        // {
        //     img: '/images/cardNav/5.jpg',
        //     text: '新品系列',
        //     en: 'New Line',
        //     url: '/pages/product/index/index'
        // }, {
        //     img: '/images/cardNav/5.jpg',
        //     text: '门店形象',
        //     en: 'Store Image ',
        //     url: '/pages/product/index/index'
        // }, 
    ]
    },
    onShow() {
        this.getTabBar().setData({
            selected: 0
        })
        wx.showShareMenu({
            menus: ['shareAppMessage', 'shareTimeline']
          })
    },
    onLoad(e) {

        this.fetch();
    },
    fetch(){
        db.collection('banner_list').get({
            success: res => {
                this.setData({
                    bannerList: res.data,
                })
                wx.stopPullDownRefresh()
            },
            fail: f => {
                console.log('f', f)
                wx.stopPullDownRefresh()
            },
        
        })
        db.collection('video_list').get({
            success: res => {
                this.setData({
                    videoList: res.data,
                })
                wx.stopPullDownRefresh()
            },
            fail: f => {
                console.log('f', f)
                wx.stopPullDownRefresh()
            },
        
        })
    },
    onBannerChange(e) {
        this.setData({
            bannerIndex: e.detail.current
        })
    },
    onPullDownRefresh(){
        this.fetch();
    },
    onShareAppMessage(){
          return {
            title: 'M里家居',
            path: '/pages/index/index',
          }
    }
})